package Login;

public class Login {
    private String useName = "admin";
    private String passWord = "123456";

    public void loginInfo(String useName, String passWord) throws UserNameException, PasswordException {
        if (!this.useName.equals(useName)) {
            throw new UserNameException("用户名有误");
        }
        if (!this.passWord.equals(passWord)) {
            throw new PasswordException("密码有误");
        }
        System.out.println("登录成功");
    }

    public static void main(String[] args) throws UserNameException, PasswordException {
        Login login = new Login();
        try{
            login.loginInfo("adin","123456");
        }catch (UserNameException e){
            e.printStackTrace();
            System.out.println("UserNameException");
        }catch (PasswordException e){
            e.printStackTrace();
            System.out.println("PasswordException");
        }
    }
}
